#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------------------
#Author:  LJ
#Email:   admin@attacker.club

#Last Modified: 2018-06-08 15:00:20
#Description: 
# --------------------------------------


import pymysql

conn = pymysql.connect(host = '192.168.66.112',port=3306,user = 'jumpserver',passwd = 'xxxxxx',db = 'jumpserver')
#打开数据库连接

cursor = conn.cursor(cursor=pymysql.cursor.DictCursor)
# 使用cursor()方法获取操作游标



#sql = """select id,hostname,ip from jasset_asset where asset_type=2 and is_active=1"""
sql = """select hostname from jasset_asset where asset_type=2 and is_active=1"""
# 创建数据表SQL语句
cursor.execute(sql)
data = cursor.fetchall()
print (data)

cursor.close() # 关闭游标
conn.close()   # 关闭数据库连接